﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.huigo.Framework.ServiceUtils;

namespace com.huigo.B2B.Web.center.order
{
    public partial class ProblemPolicy : BasePage
    {
        private int pageIndex
        {
            get
            {
                return com.loto.Common.TypeParse.StrToInt(Request.QueryString["page"], 1);
            }
        }
        public string Notiy = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void pageInfo_PageChanged(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
        private void BindData()
        {
            List<RequestFuncParams> list = new List<RequestFuncParams>();
            list.Add(new RequestFuncParams("custFid", CustId.ToString()));
            list.Add(new RequestFuncParams("pageSize", pageInfo.PageSize.ToString()));
            list.Add(new RequestFuncParams("pageIndex", pageIndex.ToString()));
            BaseService service = new BaseService();
            ParserXml parser = service.RequestEntryService(Dict.ERequestFunc.GET_PROBLEM_POLICY_LIST, list);
            if (parser != null && parser.RowsCount > 0)
            {
                pageInfo.RecordCount = Convert.ToInt16(parser["RecordCount", 0]);
                pageInfo.CurrentPageIndex = pageIndex;
                pageInfo.PageURLFormat = GetPagerUrl();
                OrderListContent.DataSource = parser.ModelList;
                OrderListContent.DataBind();
            }
            else
            {
                Notiy = "<table class=\"table table-bordered table-striped responsive-utilities table-hover\"><thead><tr><th>保单号</th><th>保险名称</th><th>被保姓名</th><th>证件号码</th><th>保单金额</th><th>保单起期</th><th>保单状态</th><th>操作</th></tr></thead><tbody><tr><td colspan=\"8\" style=\"text-align:center;\">没有相关信息</td></tr></tbody></table>";
            }
        }
        private string GetPagerUrl()
        {
            string url = "ProblemPolicy.aspx?page={0}";

            return url;
        }
        protected void OrderListContent_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.DataItem != null)
            {
                string desc = string.Empty;
                string statusDesc = ((Literal)e.Item.FindControl("statusDesc")).Text;//保单状态
                string feeDesc = ((Literal)e.Item.FindControl("feeStatus")).Text;//保单费用状态ID
                if (feeDesc == "1")
                {
                    desc = "等待支付," + statusDesc;
                }
                if (feeDesc == "2")
                {
                    desc = "支付成功," + statusDesc;
                }
                if (feeDesc == "3")
                {
                    desc = "退款成功," + statusDesc;
                }
                if (feeDesc == "4")
                {
                    desc = "退款失败," + statusDesc;
                }
                ((Literal)e.Item.FindControl("feeStatusDesc")).Text = desc;
            }
        }
    }
}
